Using Movies in Your Event Loop
Your application needs to grant time to the Movie Toolbox to allow your movies to play. To do this, you call theMoviesTask
function from your main event loop. TheMoviesTask
function (described on page 2-110) instructs the Movie Toolbox to service all your active movies. CallMoviesTask
regularly so that your movie can play smoothly. You can use theUpdateMovie
function to force your movie to be redrawn after it has been uncovered. It will not be redrawn until the next call toMoviesTask
.Your application should call
UpdateMovie
between the Window Manager'sBeginUpdate
andEndUpdate
functions. (For details onBeginUpdate
andEndUpdate
, see Inside Macintosh: Macintosh ToolBox Essentials Essentials.) Do not callMoviesTask
at this time. You will observe better display behavior if you callMoviesTask
at the end of your update processing.The code shown in Listing 2-13 demonstrates the use of the
UpdateMovie
function in a Window Manager update sequence. For the Movie Toolbox to know that it has to display (or update) a movie whenMoviesTask
is called, you must callUpdateMovie
as shown. If you are using the movie controller component and call theMCIsPlayerEvent
function, you do not need to callUpdateMovie
in response to an update event. (See the chapter "Movie Controller Component" in Inside Macintosh: QuickTime Components, for details onMCIsPlayerEvent
.)
The
- Note
- Contrary to normal update handling, where applications draw to the window in between calls to
BeginUpdate
andEndUpdate
, you should not callMoviesTask
.![]()
UpdateMovie
function tells the Movie Toolbox that a portion of the movie has been invalidated. However, it is not redrawn untilMoviesTask
is called.Listing 2-13 Handling movie update events
#include <Events.h>#include <ToolUtils.h>#include "Movies.h" void DoUpdate (WindowPtr theWindow, Movie theMovie) { BeginUpdate (theWindow); UpdateMovie (theMovie); EndUpdate (theWindow); } /* DoUpdate */